<%@page import="interfaces.DALException"%>
<%@page import="java.util.List"%>
<%@page import="dto_objects.*"%>
<%@page import="java.util.ArrayList"%>
<%@page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>

<% 
String login = "<form action=\"LoginServlet\">"+
		"Username:<br>"+
		"<input type=\"text\" name=\"un\"><br>"+
		"Password:<br>"+
		"<input type=\"text\" name=\"pw\">"+
		"<input type=\"submit\" value=\"log In\">"+
		"&nbsp;"+
		"</form>";
%>

<script type="text/javascript" src="../javascripts/jquery-latest.pack.js"></script>
<script type="text/javascript" src="../javascripts/popup.js"></script>

<jsp:useBean id="func" class="Function.FunctionUSER" scope="session"/>  

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
	<title>Faktura</title>
	<link rel="stylesheet" type="text/css" href="../NewStyle.css">
</head>
<body>
	<div id=topBox>
			<div id=searchField>
				<form action="../Web/MainPage.jsp">
				<input type="text" name="searchText"> 
				<input type="submit" value="">
				<a id="aSearchButton" href="../Search/aSearch.jsp">Advanced search</a>
				</form>			
			</div>
	
			<div id=login>
				<%out.print(func.getClass().getName());
				if(session.getAttribute("currentSessionUser") == null){
					session.setAttribute("userMENU", null);
					out.print("<a class=myButton href=\"#loginField\" name=\"loginFieldClick\">Login</a>");
				}else{
					out.print("<form action=\"../LoginServlet\">"+
							"<input class=myButton type=\"submit\" value=\"Log Out\" name=\"logout\">"+
							"</form>");
				}
				%>
				
				
			</div>
	</div>
	<div id=main>
		<div id=header>

		</div>
		<div id=content>
			<div id=data>
		
	<%

	UserDTO User = (UserDTO) session.getAttribute("currentSessionUser");
	
	int userID = User.getUsrID();
	
	List<FakturaDTO> fakturaList = func.showCurrentLoans(userID, 1);
	out.print("<p style=\"font-size:18pt;\">Receipts</p><hr>");
	for(int x=0;x<fakturaList.size();x++){
		int ISBN = func.getISBNByBookCopyID(fakturaList.get(x).getBookID());
		out.print("<br><img style=\"padding-right: 20px; padding-left: 20px;\" align=\"left\" src=\"../images/receipt.png\" alt=\"Error\" height=\"200\" width=\"150\">");
			out.print("<span>User ID: </span>"+fakturaList.get(x).getUsrID()+"<br>");
   			out.print("<span>Faktura ID: </span>"+fakturaList.get(x).getFakID()+"<br>");
   			out.print("<span>Book: </span>"+"<a href=\"../Web/showBook.jsp?ISBN="+ISBN+"\">"+ISBN+"</a><br>");
   			out.print("<span>Loan Date: </span>"+fakturaList.get(x).getLoan_date()+"<br>");
   			out.print("<span>Loan Due: </span>"+fakturaList.get(x).getLoan_due()+"<br>");
   			out.print("<br><br><br><br><br><hr>");
	}
	%>
	

</div>
		
			<div>
		${userMENU}
		</div>
<div id="loginField" class="window">
	<form action="../LoginServlet">
			Username:
			<input type="text" name="un"><br>
			Password:
			<input type="text" name="pw"><br>
			<input type="submit" value="Log In">
		</form>	
		<br>
	<a href="#"class="close" align=right style="color: #333;text-align: right;text-decoration: none;">Close</a>
</div>	
<div id="mask"></div>

</body>
</html>